package free.mrchen.boot.gate.server.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

import java.util.logging.Logger;


@Component
public class CustomGlobalFilter implements GlobalFilter {

    static final Logger log = Logger.getLogger(CustomGlobalFilter.class.getName());

    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        final long startTime = System.currentTimeMillis();
        System.out.println("11ggg");
        try {
            return chain.filter(exchange);
        } finally {
            log.info( exchange.getRequest().getPath() + " use " + (System.currentTimeMillis() - startTime) + " ms" );
        }
    }



}
